<?php
include 'admin_config_lib.php';

$a_css_files = array (
    array ( 'path' => 'plugins/bootstrap-modal/css/bootstrap-modal.css' ),
);

$a_js_files = array (
    array ( 'path' => 'plugins/jquery-file-upload/js/vendor/tmpl.min.js' ),
    array ( 'path' => 'plugins/bootstrap-modal/js/bootstrap-modal.js' ),
    array ( 'path' => 'plugins/bootstrap-modal/js/bootstrap-modalmanager.js' ),
    array ( 'path' => 'plugins/jquery-validation/dist/jquery.validate.min.js' ),
    array ( 'path' => 'scripts/nh-admin-config.js' ),
);

$a_js_class[] = 'NH_Config.init();';

$a_Phieu_DiemDanh = $a_NganhHoc = $a_CapHoc = $a_DoiHoc = $a_PhanBan_TaiKhoan = $a_LoaiTaiKhoan = $a_XepHangThanhTich = $a_Moi_Quan_He = $a_DotKiemTra = $a_LanKiemTra = array ( );

// <editor-fold defaultstate="collapsed" desc="Get Data">
$db_query  = db_get_query($a_tablecolumns_namhoa_system_option) . "
            where option_type in ('" . implode("', '", array_keys($a_Loai_ChuyenCan)) . "' ,
                  'NGANH', 'CAP', 'DOI', 'PHAN_BAN', 'LOAI_TAI_KHOAN', 'XEP_HANG', 'MOI_QUAN_HE', 'DOT_KIEM_TRA', 'LAN_KIEM_TRA')
            order by option_type desc, option_key";
$db_result = db_query($db_conn, $db_query);

while ($d_row = db_fetch($db_result)) {
    if (in_array($d_row->option_type, array_keys($a_Loai_ChuyenCan))) {
        $d_row->option_data  = json_decode($d_row->option_data);
        $d_row->option_score = $d_row->option_data->option_score;
        $d_row->option_name  = $d_row->option_data->option_name;

        unset($d_row->option_data);

        $a_Phieu_DiemDanh[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'NGANH') {
        $a_NganhHoc[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'CAP') {
        $a_CapHoc[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'DOI') {
        $a_DoiHoc[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'PHAN_BAN') {
        $a_PhanBan_TaiKhoan[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'LOAI_TAI_KHOAN') {
        $a_LoaiTaiKhoan[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'XEP_HANG') {
        $a_XepHangThanhTich[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'MOI_QUAN_HE') {
        $a_Moi_Quan_He[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'DOT_KIEM_TRA') {
        $a_DotKiemTra[$d_row->option_id] = $d_row;
    }
    else if ($d_row->option_type == 'LAN_KIEM_TRA') {
        $a_LanKiemTra[$d_row->option_id] = $d_row;
    }
}
// </editor-fold>

$a_permission = get_passport_action_from_module($db_conn, array('THONG_SO'));
$s_Hidden_Class = !in_array('update-permission', $a_permission) ? 'hidden' : '';

include 'lib_head.php';
?>
<div id="ajax-modal" class="modal hide fade" tabindex="-1"></div>
<div class="row-fluid">
    <div class="span4">
        <div class="portlet box green">
            <div class="portlet-title">
                <div class="caption"><i class="icon-info"></i>Khóa Học <?=$a_KhoaHoc_Info['name']?></div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ngày Bắt Đầu</th>
                            <th style="text-align: center;">Ngày Kết Thúc</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><div class="text-center"><?=$a_KhoaHoc_Info['start']?></div></td>
                            <td><div class="text-center"><?=$a_KhoaHoc_Info['end']?></div></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="span8">
        <div class="portlet box red">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Phiếu Điểm Danh</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_attendance_card">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Loại</th>
                            <th style="text-align: center;">Tên</th>
                            <th style="text-align: center;">Điểm Trừ</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_Phieu_DiemDanh as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_attendance_card">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><?= @$a_Loai_ChuyenCan[$o_Temp->option_type] ?></td>
                                <td><div class="bold"><?= $o_Temp->option_name ?></div></td>
                                <td><div class="text-center"><?= $o_Temp->option_score ?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div class="span4">
        <div class="portlet box purple">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Xếp Hạng Thành Tích</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_userrank">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_XepHangThanhTich as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_userrank">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="span4">
        <div class="portlet box green">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Đợt Kiểm Tra</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_examtype">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_DotKiemTra as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_examtype">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="span4">
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Lần Kiểm Tra</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_examtime">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_LanKiemTra as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_examtime">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div class="span4">
        <div class="portlet box green">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Loại Tài Khoản</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_usertype">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_LoaiTaiKhoan as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_usertype">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="span4">
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Phân Ban</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_usercrew">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên Ban</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_PhanBan_TaiKhoan as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_usercrew">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>    
    <div class="span4">
        <div class="portlet box purple">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Mối Quan Hệ</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_relationship">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_Moi_Quan_He as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_relationship">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div class="span4">
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Ngành</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_team">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên Ngành</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_NganhHoc as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_team">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="span4">
        <div class="portlet box green">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Cấp</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_level">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên Cấp</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_CapHoc as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_level">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="span4">
        <div class="portlet box purple">
            <div class="portlet-title">
                <div class="caption"><i class="icon-bell"></i>Đội</div>
                <div class="actions">
                    <div class="btn-group <?=$s_Hidden_Class?>">
                        <a class="btn" id="modal_ajax_btn_add_crew">
                            <i class="icon-plus"></i>
                            Tạo Mới
                        </a>
                    </div>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Ký Hiệu</th>
                            <th style="text-align: center;">Tên Đội</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($a_DoiHoc as $key => $o_Temp) { ?>
                            <tr>
                                <td option_id="<?= $o_Temp->option_id ?>">
                                    <div class="bold"><?= $o_Temp->option_key ?></div>
                                    <a class="btn mini yellow-stripe <?=$s_Hidden_Class?> modal_ajax_btn_update_crew">
                                        <i class="icon-pencil"></i>
                                        Sửa
                                    </a>
                                </td>
                                <td><div class="bold"><?= $o_Temp->option_data?></div></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?php include 'lib_tail.php'; ?>